using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FiltronASP.Models;
using FiltronASP.Models.DAO.Filtron;
using FiltronASP.Models.DAO.WIX;
using FiltronASP.Models.DAO.Extensions;
using FiltronASP.Models.DAO.Interfaces.Filtron;
using FiltronASP.Models.DAO.Interfaces.WIX;
using FiltronASP.Helpers.Translations;
using FiltronASP.Helpers.CatalogueHelpers;
using System.IO;
using System.Net;
using System.Text;
using FiltronASP.Helpers.Instructions;

namespace FiltronASP.Helpers.AjaxModel
{
    /// <summary>
    /// Klasa pomocnicza do generowania stringa z lista modeli.
    /// </summary>
    public static class ModelHelperFiltron
    {
        /// <summary>
        /// Metoda generujaca string do comba na podstawie id marki.
        /// </summary>
        /// <param name="makeId">marka</param>
        /// <returns>string</returns>
        public static string GetModelComboString(int makeId, string languageName)
        {
            string comboString = translationHelper.getTranslation("_selectModel", languageName) + "|-1;";
            IFiltronModelDAO filtronModelDAO = new FiltronModelDAO();
            if (makeId > 0)
            {
                IQueryable<FiltronModel> filtronModels = filtronModelDAO.FindByMake(makeId);
                if (filtronModels != null)
                {
                    foreach (FiltronModel model in filtronModels)
                    {
                        comboString += model.model_name;
                        comboString += "|";
                        comboString += model.model_id;
                        comboString += ";";
                    }   //foreach
                }   //if
            }   //if
            return comboString;
        }

        /// <summary>
        /// Metoda generujaca diva leftSearchSide do silnikow na podstawie id modelu.
        /// </summary>
        /// <param name="modelId">model</param>
        /// <returns>string</returns>
        public static string GetEngineDivString(int modelId, string languageName)
        {
            if (modelId.Equals(0))
            {
                return null;
            }
            if (languageName == "")
            {
                return null;
            }
            return Helpers.AjaxModel.EngineTableHelper.generateEngineTable(modelId, languageName);
        }

        /// <summary>
        /// Metoda generujaca diva leftSearchSide do silnikow.
        /// </summary>
        /// <returns>string</returns>
        public static string GetEngineDivString()
        {
            return String.Empty;
        }

        /// <summary>
        /// Metoda generująca listę marek na podstawie typu pojazdu. (vehicle)
        /// </summary>
        /// <param name="vehicleId">typ pojazdu</param>
        /// <returns>string</returns>
        public static string getBrandDropDownByVehicleId(string vehicleId, string languageName)
        {
            string comboString = translationHelper.getTranslation("_selectManufacturer", languageName) + ",-1;";
            IFiltronMakeDAO filtronMakesDAO = new FiltronMakeDAO();
            IWixMakeDAO WixMakeDAO = new WixMakeDAO();
            // sprawdzam czy odebrane value ma po przecinku 'w', jeśli tak to pobieram kolekcję z bazy Wix'a, jeśli nie - Filtron.
            if (vehicleId != "")
            {
                string[] explodedVid = vehicleId.Split(',');
                if (explodedVid.Length == 1)
                {
                    IQueryable<FiltronMake> filtronMakes = filtronMakesDAO.FindByVehicle(int.Parse(vehicleId));
                    if (filtronMakes != null)
                    {
                        foreach (FiltronMake make in filtronMakes)
                        {
                            comboString += make.make_name;
                            comboString += ",";
                            comboString += make.make_id;
                            comboString += ";";
                        }
                    }   //if
                }
                else
                {
                    if (explodedVid[1] == "w")
                    {
                        IQueryable<WixMake> wixMakesCollection = WixMakeDAO.FindByVehicle(int.Parse(explodedVid[0]));
                        if (wixMakesCollection != null)
                        {
                            foreach (WixMake make in wixMakesCollection)
                            {
                                comboString += make.make_name;
                                comboString += ",";
                                comboString += make.make_id;
                                comboString += ";";
                            }
                        }
                    }
                }
            }
            return comboString;
        }

      


        public static string GetFiltersByEngineAndModel(int engineId, int modelId, string languageName)
        {
            if (engineId.Equals(0))
            {
                return null;
            }
            if (modelId.Equals(0))
            {
                return null;
            }
            if (languageName == "")
            {
                return null;
            }

            return Helpers.AjaxModel.FiltersTableHelper.generateFiltersTable(engineId, modelId, languageName, 2);
        }

        public static string generateSingleFilter(int filterId, string languageName, bool isHdTruck)
        {
            IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
            FiltronFilter filter = filtronFilterDAO.FindByPK(filterId);
            StringBuilder sb = new StringBuilder();

            string filterXML750 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + "/0750/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + "_out.xml");
            string filterXML1500 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + "/1500/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + "_out.xml");
            if (File.Exists(filterXML750))
            {
                sb.Append(String.Format("<div id='container360' class='threesixty car' data-number='{0}'>", FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
                sb.Append("<div class='slider-filter-name'>");
                sb.Append(String.Format("<p>{0}</p>", FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
                sb.Append("</div>");
                sb.Append("<div class='spinner'>");
                sb.Append("<span>0%</span>");
                sb.Append("</div>");
                sb.Append("<ol class='threesixty_images'></ol>");
                sb.Append("</div>");
                if (File.Exists(filterXML1500))
                {
                    sb.Append("<div id='container360fullscreen' style='display: none;' class='threesixty car'>");
                    sb.Append("<div class='slider-filter-name'>");
                    sb.Append(String.Format("<p>{0}</p>", FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
                    sb.Append("</div>");
                    sb.Append("<div class='spinner'>");
                    sb.Append("<span>0%</span>");
                    sb.Append("</div>");
                    sb.Append("<ol class='threesixty_images'></ol>");
                    sb.Append("</div>");
                }
            }
            else
            {
                filterXML750 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + "/0750/3648_out.xml");
                filterXML1500 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + "/1500/3648_out.xml");
                if (File.Exists(filterXML750))
                {
                    sb.Append(String.Format("<div id='container360' class='threesixty car' data-number='{0};3648'>", FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
                    sb.Append("<div class='slider-filter-name'>");
                    sb.Append(String.Format("<p>{0}</p>", filter.filter_number));
                    sb.Append("</div>");
                    sb.Append("<div class='spinner'>");
                    sb.Append("<span>0%</span>");
                    sb.Append("</div>");
                    sb.Append("<ol class='threesixty_images'></ol>");
                    sb.Append("</div>");
                    if (File.Exists(filterXML1500))
                    {
                        sb.Append(String.Format("<div id='container360fullscreen' style='display: none;' class='threesixty car' data-number='{0};3648'>", FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
                        sb.Append("<div class='slider-filter-name'>");
                        sb.Append(String.Format("<p>{0}</p>", filter.filter_number));
                        sb.Append("</div>");
                        sb.Append("<div class='spinner'>");
                        sb.Append("<span>0%</span>");
                        sb.Append("</div>");
                        sb.Append("<ol class='threesixty_images'></ol>");
                        sb.Append("</div>");
                    }
                }
                else
                {
                    string imageFilter = HttpContext.Current.Server.MapPath("~/Content/img/filters/Filtron/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + ".jpg");
                    if (File.Exists(imageFilter))
                    {
                        sb.Append("<div id='notfound360' style='width: 100%; text-align: center;' class='col-xs-12'>");
                        sb.Append(String.Format("<a href='{0}' data-lightbox='image-1' data-title='{1}'>", VirtualPathUtility.ToAbsolute("~/Content/img/filters/Filtron/large/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + ".jpg"), FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
                        sb.Append("<img src='" + VirtualPathUtility.ToAbsolute("~/Content/img/filters/Filtron/" + FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck) + ".jpg") + "' alt='' />");
                        sb.Append(String.Format("<img class='no-360-magnifi' src='{0}' alt='lupa'>", VirtualPathUtility.ToAbsolute("~/Content/img/lupa-yellow.png")));
                        sb.Append("</a>");
                        sb.Append("</div>");
                    }
                    else
                    {
                        imageFilter = HttpContext.Current.Server.MapPath("~/Content/img/filters/" + filter.filter_number + ".png");
                        if (File.Exists(imageFilter))
                        {
                            sb.Append("<div id='notfound360' style='width: 100%; text-align: center;' class='col-xs-12'>");
                            sb.Append(String.Format("<a href='{0}' data-lightbox='image-1' data-title='{1}'>", VirtualPathUtility.ToAbsolute("~/Content/img/filters/" + filter.filter_number + ".png"), filter.filter_number));
                            sb.Append("<img src='" + VirtualPathUtility.ToAbsolute("~/Content/img/filters/thumbnails/" + filter.filter_number + ".png") + "' alt='' />");
                            sb.Append(String.Format("<img class='no-360-magnifi' src='{0}' alt='lupa'>", VirtualPathUtility.ToAbsolute("~/Content/img/lupa-yellow.png")));
                            sb.Append("</a>");
                            sb.Append("</div>");
                        }
                        else
                        {
                            IFiltronFilterMediaDAO filtronFilterMediaDAO = new FiltronFilterMediaDAO();
                            FiltronFilterMedia filterMedia = filtronFilterMediaDAO.FindByPK(filter.filter_media_id);
                            string orgFilterMedia = String.Empty;
                            if (filterMedia != null)
                            {
                                orgFilterMedia = filterMedia.media_name;
                                string repImageName = FiltronHelper.GetFiltronFilterImage(orgFilterMedia);
                                imageFilter = HttpContext.Current.Server.MapPath(String.Format("~/Content/img/filters/Filtron/{0}.jpg", repImageName));
                                if (File.Exists(imageFilter))
                                {
                                    sb.Append("<div id='notfound360' style='width: 100%; text-align: center;' class='col-xs-12'>");
                                    sb.Append(String.Format("<a href='{0}' data-lightbox='image-1' data-title='{1}'>", VirtualPathUtility.ToAbsolute(String.Format("~/Content/img/filters/Filtron/large/{0}.jpg", repImageName)), repImageName));
                                    sb.Append("<img src='" + VirtualPathUtility.ToAbsolute(String.Format("~/Content/img/filters/Filtron/{0}.jpg", repImageName)) + "' alt='' />");
                                    sb.Append(String.Format("<img class='no-360-magnifi' src='{0}' alt='lupa'>", VirtualPathUtility.ToAbsolute("~/Content/img/lupa-yellow.png")));
                                    sb.Append("</a>");
                                    sb.Append("</div>");
                                }
                                else
                                {
                                    if (languageName == "polish")
                                    {
                                        sb.Append("<div id='notfound360' style='width: 100%; height: 500px; text-align: center;' class='col-xs-12'><img style='position: relative; top: 100px;' src='" + VirtualPathUtility.ToAbsolute("~/Content/img/temp/example_filter.png") + "' alt='' /></div>");
                                    }
                                    else
                                    {
                                        sb.Append("<div id='notfound360' style='width: 100%; height: 500px; text-align: center;' class='col-xs-12'><img style='position: relative; top: 100px;' src='" + VirtualPathUtility.ToAbsolute("~/Content/img/temp/example_filter_english.png") + "' alt='' /></div>");
                                    }   //else
                                }
                            }
                            else
                            {

                                if (languageName == "polish")
                                {
                                    sb.Append("<div id='notfound360' style='width: 100%; height: 500px; text-align: center;' class='col-xs-12'><img style='position: relative; top: 100px;' src='" + VirtualPathUtility.ToAbsolute("~/Content/img/temp/example_filter.png") + "' alt='' /></div>");
                                }
                                else
                                {
                                    sb.Append("<div id='notfound360' style='width: 100%; height: 500px; text-align: center;' class='col-xs-12'><img style='position: relative; top: 100px;' src='" + VirtualPathUtility.ToAbsolute("~/Content/img/temp/example_filter_english.png") + "' alt='' /></div>");
                                }   //else
                            }
                        }   //else
                    }   //else
                }   //else
            }   //else

            
            sb.Append("<div class='col-xs-12 no-padding under-360-gallery'>");

            // ### SMALL IMAGES ###
            sb.Append(SingleFilterImagesHelper.generateFirstFilterPhoto(FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck), filter.filter_media_id, languageName));
            sb.Append(SingleFilterImagesHelper.generateSecondFilterPhoto(FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck), languageName));
            sb.Append(SingleFilterImagesHelper.generateThirdFilterPhoto(FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck), languageName));
            sb.Append(SingleFilterImagesHelper.generateFourthFilterPhoto(FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck), languageName));
            // ### SMALL IMAGES ###

            sb.Append("</div>");
            sb.Append("<div class='col-xs-12 desc-filter no-padding'>");
            sb.Append("<div class='col-md-12 col-xs-12 ' id='desc-filter-dim-id'>");

            sb.Append(String.Format("<h4>{0} (MM):</h4>", translationHelper.getTranslation("_hlpSizes", languageName).ToUpper()));

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>A: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_a)));
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>B: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_b)));
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>C: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_c)));
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>D: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_d)));
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>E: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_e)));
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>F: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_f)));
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>G: </span>");
            if (filter.filter_dim_g_text != null)
            {
                sb.Append(String.Format("<span>{0}</span>", filter.filter_dim_g_text));
            }   //if
            else
            {
                sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_g)));
            }   //else
            sb.Append("</div>");

            sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
            sb.Append("<span>H: </span>");
            sb.Append(String.Format("<span>{0}</span>", SingleFilterHelper.parseFilterSizes(filter.filter_dim_h)));
            sb.Append("</div>");


            sb.Append("</div>");

            sb.Append("<div class='col-md-12 col-xs-12' id='desc-filter-appl-id'>");
            sb.Append(String.Format("<h4>{0}:</h4>", translationHelper.getTranslation("_hlpApplication", languageName).ToUpper()));
            sb.Append("<div class='dimen-v2 dimen-item'>");
            sb.Append(String.Format("<span style='font-weight: normal'>{0}</span>", filter.filter_principle_applications));
            sb.Append("</div>");
            sb.Append("</div>");

            string byPassValve = translationHelper.getTranslation("_hlpNo", languageName);
            string antiDrain = translationHelper.getTranslation("_hlpNo", languageName);
            string antiSyphon = translationHelper.getTranslation("_hlpNo", languageName);
            if (filter.filter_by_pass_valve == true)
            {
                byPassValve = translationHelper.getTranslation("_hlpYes", languageName);
            }
            if (filter.filter_anti_drain_valve == true)
            {
                antiDrain = translationHelper.getTranslation("_hlpYes", languageName);
            }
            if (filter.filter_anti_siphon_valve == true)
            {
                antiSyphon = translationHelper.getTranslation("_hlpYes", languageName);
            }


            sb.Append("<div class='col-md-12 col-xs-12' id='desc-filter-other-id'>");
            sb.Append(String.Format("<h4>{0}:</h4>", translationHelper.getTranslation("_hlpOther", languageName).ToUpper()));

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpByPassValve", languageName), byPassValve));
            sb.Append("</div>");

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpAntiDrain", languageName), antiDrain));
            sb.Append("</div>");

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpAntiSiphon", languageName), antiSyphon));
            sb.Append("</div>");
            string instructionPdf = FilterInstructions.getFilterInstruction(FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck), Convert.ToString(filter.filter_number_trim));
            if (instructionPdf.Length > 0)
            {
                sb.Append("<div class='col-xs-12 no-padding'>");
                sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'><a target='_blank' href='{1}'>{2}</a></span>", translationHelper.getTranslation("_hlpInstruction", languageName), instructionPdf, translationHelper.getTranslation("_downloadPDF", languageName)));
                sb.Append("</div>");
            }
            else
            {
                sb.Append("<div class='col-xs-12 no-padding'>");
                sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>---</span>", translationHelper.getTranslation("_hlpInstruction", languageName)));
                sb.Append("</div>");
            }   //else
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append(String.Format("<div style='display:none' id='desc-filter-number-id'>{0}</div>", FiltronHelper.GetFiltronFilterNumber(filter, isHdTruck)));
            sb.Append(ModelHelper.generatePopup(ModelHelper.generatePopupInfoLogisticsContentFiltron(filterId, "popupClose", languageName), "popupLogisticsInfo", "popupClose", false, 220));
            sb.Append(ModelHelper.generatePopup(ModelHelper.generatePopupOeNumbersContentFiltron(filterId, "popupOeClose"), "popupOeNumbers", "popupOeClose", true));
            sb.Append(ModelHelper.generatePopup(ModelHelper.generatePopupMail(filterId, "popupMailClose", languageName), "popupMail", "popupMailClose", true));
            sb.Append(ModelHelper.generatePopup(ModelHelper.generatePopupFullSizeGallery(filterId, "popupGalClose"), "popupGal", "popupGallClose", true));
            return sb.ToString();
        }

        public static string generateSearchedFilterDescription(string manufacturer, string filter_number, string languageName)
        {
            string htmlToReturn = String.Empty;

            if (manufacturer.Equals("filtron"))
            {
                IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
                IQueryable<FiltronFilter> filtersCollection = filtronFilterDAO.FindByFilterNumber(filter_number);
                if (filtersCollection != null)
                {
                    FiltronFilter filterToDesc = filtersCollection.First();

                    htmlToReturn += "<div class=\"replacementsDescription\">";
                    htmlToReturn += "<div class=\"searchRightSideTop\" id=\"searchRightSideTop\">";
                    htmlToReturn += "                <div id=\"searchRightSideTopLeft\">";
                    htmlToReturn += "                    <h3>" + translationHelper.getTranslation("_filter", languageName) + " <span>" + FiltronHelper.GetFiltronFilterNumber(filterToDesc) + "</span></h3>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftDimensions\">";
                    htmlToReturn += "                        <strong>" + translationHelper.getTranslation("_hlpSizes", languageName) + " (mm):</strong>";
                    htmlToReturn += "                        <table>";
                    string sizeG = String.Empty;
                    string sizeF = String.Empty;
                    if (filterToDesc.filter_dim_g_text != null) { sizeG = filterToDesc.filter_dim_g_text; } else { sizeG = Convert.ToString(SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_g)); }
                    if (filterToDesc.filter_dim_f_text != null) { sizeF = filterToDesc.filter_dim_f_text; } else { sizeF = Convert.ToString(SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_f)); }

                    htmlToReturn += "                            <tr><td>A: <span>" + SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_a) + "</span></td><td>B: <span>" + SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_b) + "</span></td><td>C: <span>" + SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_c) + "</span></td></tr>";
                    htmlToReturn += "                            <tr><td>D: <span>" + SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_d) + "</span></td><td>E: <span>" + SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_e) + "</span></td><td>F: <span>" + sizeF + "</span></td></tr>";
                    htmlToReturn += "                            <tr><td>G: <span>" + sizeG + "</span></td><td>H: <span>" + SingleFilterHelper.parseFilterSizes(filterToDesc.filter_dim_h) + "</span></td></tr>";
                    htmlToReturn += "                        </table>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftInfo\">";
                    htmlToReturn += "                        <ul>";
                    string byPassValve = translationHelper.getTranslation("_hlpNo", languageName);
                    string antiDrain = translationHelper.getTranslation("_hlpNo", languageName);
                    string antiSyphon = translationHelper.getTranslation("_hlpNo", languageName);
                    if (filterToDesc.filter_by_pass_valve == true)
                    {
                        byPassValve = translationHelper.getTranslation("_hlpYes", languageName);
                    }
                    if (filterToDesc.filter_anti_drain_valve == true)
                    {
                        antiDrain = translationHelper.getTranslation("_hlpYes", languageName);
                    }
                    if (filterToDesc.filter_anti_siphon_valve == true)
                    {
                        antiSyphon = translationHelper.getTranslation("_hlpYes", languageName);
                    }
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpByPassValve", languageName) + ": <span>{0}</span></li>", byPassValve);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpAntiDrain", languageName) + ": <span>{0}</span></li>", antiDrain);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpAntiSiphon", languageName) + ": <span>{0}</span></li>", antiSyphon);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpInstruction", languageName) + ": <span>{0}</span></li>", String.Empty);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpApplication", languageName) + ":<br/><span>{0}</span></li>", filterToDesc.filter_principle_applications);
                    htmlToReturn += "                        </ul>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                    htmlToReturn += "                        <img src=\"../../../Content/images/engine_printer.jpg\" alt=\"Printer\" /> <span class=\"desc_commands\">" + translationHelper.getTranslation("_hlpPrint", languageName) + "</span>";
                    htmlToReturn += "                        <img src=\"../../../Content/images/engine_mail.jpg\" alt=\"Mail\" /> <span class=\"desc_commands\">" + translationHelper.getTranslation("_hlpSend", languageName) + "</span>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                    htmlToReturn += "                        <img onclick=\"" + ModelHelper.showPopup("popupLogisticsInfo") + "\" src=\"../../../Content/images/logistics.png\" alt=\"Logistics Info\" /><span onclick=\"" + ModelHelper.showPopup("popupLogisticsInfo") + "\" class=\"desc_commands\">Logistics Info</span>";  //bez translacji
                    htmlToReturn += "                        <img onclick=\"" + ModelHelper.showPopup("popupOeNumbers") + "\" src=\"../../../Content/images/oe.png\" alt=\"OE\" /> <span onclick=\"" + ModelHelper.showPopup("popupOeNumbers") + "\" class=\"desc_commands\">OE</span>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                </div>";
                    htmlToReturn += "                <div id=\"searchRightSideTopRightFiltron\">";

                    string imgPath = @"http://wixeurope.com/Content/images/filters/Filtron/" + FiltronHelper.GetFiltronFilterNumber(filterToDesc) + ".jpg";
                    string imgUrl = String.Empty;
                    string imgUrlLarge = String.Empty;
                    bool showZoom = true;
                    var request = (HttpWebRequest)WebRequest.Create(imgPath);
                    request.Method = "HEAD";
                    try
                    {
                        var response = (HttpWebResponse)request.GetResponse();
                        imgUrl = imgPath;
                        imgUrlLarge = @"http://wixeurope.com/Content/images/filters/Filtron/large/" + FiltronHelper.GetFiltronFilterNumber(filterToDesc) + ".jpg";
                    }
                    catch
                    {
                        IFiltronFilterMediaDAO filtronFilterMediaDAO = new FiltronFilterMediaDAO();
                        FiltronFilterMedia filterMedia = filtronFilterMediaDAO.FindByPK(filterToDesc.filter_media_id);
                        string orgFilterMedia = String.Empty;
                        if (filterMedia != null)
                        {
                            orgFilterMedia = filterMedia.media_name;
                            string RepImageName = FiltronHelper.GetFiltronFilterImage(orgFilterMedia);
                            imgUrl = String.Format(@"http://wixeurope.com/Content/images/filters/Filtron/{0}.jpg", RepImageName);
                        }
                        showZoom = false;
                    }

                    htmlToReturn += "                    <img src=\"" + imgUrl + "\" alt=\"Example\" />";
                    if (showZoom)
                        htmlToReturn += "                    <a href=\"" + imgUrlLarge + "\" rel=\"lightbox\"><span>" + translationHelper.getTranslation("_hlpZoom", languageName) + " <img src=\"../../../Content/images/engine_magn.png\" alt=\"Zoom\" /></a></span>";
                    htmlToReturn += "                </div>";
                    htmlToReturn += "            </div>";
                    htmlToReturn += "</div>";
                }
                else
                {
                    return "<div id=\"ajaxStatementInfo\">" + Translations.translationHelper.getTranslation("_searchNoFilters", languageName) + "</div>";
                }
            } // if filtron
            else if (manufacturer.Equals("wix"))
            {
                IWixFilterDAO wixFilterDAO = new WixFilterDAO();
                IQueryable<WixFilter> filtersCollection = wixFilterDAO.FindByFilterNumber(filter_number);
                if (filtersCollection != null)
                {
                    WixFilter filterToDesc = filtersCollection.First();
                    htmlToReturn += "<div class=\"replacementsDescription\">";
                    htmlToReturn += "<div class=\"searchRightSideTop\" id=\"searchRightSideTop\">";
                    htmlToReturn += "                <div id=\"searchRightSideTopLeft\">";
                    htmlToReturn += "                    <h3>" + translationHelper.getTranslation("_filter", languageName) + " <span>" + filterToDesc.filter_number + "</span></h3>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftDimensions\">";
                    htmlToReturn += "                        <strong>" + translationHelper.getTranslation("_hlpSizes", languageName) + " (mm):</strong>";
                    htmlToReturn += "                        <table>";
                    if (filterToDesc.filter_outside_dia_top > 0)
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterTop", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filterToDesc.filter_outside_dia_top)) + "</span></td></tr>";
                    }
                    else
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterTop", languageName) + ": <span> --- </span></td></tr>";
                    }

                    if (filterToDesc.filter_outside_dia_bottom > 0)
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterBottom", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filterToDesc.filter_outside_dia_bottom)) + "</span></td></tr>";
                    }
                    else
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterBottom", languageName) + ": <span> --- </span></td></tr>";
                    }
                    if (filterToDesc.filter_inside_dia_top > 0)
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_innerDiameter", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filterToDesc.filter_inside_dia_top)) + "</span></td></tr>";
                    }
                    else
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_innerDiameter", languageName) + ": <span> --- </span></td></tr>";
                    }
                    if (filterToDesc.filter_height > 0)
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_height", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filterToDesc.filter_height)) + "</span></td></tr>";
                    }
                    else
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_height", languageName) + ": <span> --- </span></td></tr>";
                    }
                    if (filterToDesc.filter_thread_size != null)
                    {
                        htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_threadSize", languageName) + ": <span>" + filterToDesc.filter_thread_size + "</span></td></tr>";
                    }
                    htmlToReturn += "                        </table>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftInfo\">";
                    htmlToReturn += "                        <ul>";

                    string filterStyle = "---";
                    string filterType = "---";
                    string filterMedia = "---";
                    string filterService = "---";
                    if ((filterToDesc.filter_style_id > 0) && (filterToDesc.filter_style_id != null))
                    {
                        filterStyle = SingleFilterHelper.getFilterStyle(Convert.ToInt32(filterToDesc.filter_style_id));
                    }
                    if ((filterToDesc.filter_type_id > 0) && (filterToDesc.filter_type_id != null))
                    {
                        filterType = SingleFilterHelper.getFilterType(Convert.ToInt32(filterToDesc.filter_type_id));
                    }
                    if ((filterToDesc.filter_media_id > 0) && (filterToDesc.filter_media_id != null))
                    {
                        filterMedia = SingleFilterHelper.getMediaType(Convert.ToInt32(filterToDesc.filter_media_id));
                    }
                    if ((filterToDesc.filter_service_id > 0) && (filterToDesc.filter_service_id != null))
                    {
                        filterMedia = SingleFilterHelper.getFilterService(Convert.ToInt32(filterToDesc.filter_service_id));
                    }

                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterStyle", languageName) + ": <span>{0}</span></li>", filterStyle);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterType", languageName) + ": <span>{0}</span></li>", filterType);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterMedia", languageName) + ": <span>{0}</span></li>", filterMedia);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterService", languageName) + ": <span>{0}</span></li>", filterService);

                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpInstruction", languageName) + ": <span>{0}</span></li>", String.Empty);
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpApplication", languageName) + ":<br/><span>{0}</span></li>", filterToDesc.filter_principle_applications);
                    htmlToReturn += "                        </ul>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                    htmlToReturn += "                        <img src=\"../../../Content/images/engine_printer.jpg\" alt=\"Printer\" /> <span class=\"desc_commands\">" + translationHelper.getTranslation("_hlpPrint", languageName) + "</span>";
                    htmlToReturn += "                        <img src=\"../../../Content/images/engine_mail.jpg\" alt=\"Mail\" /> <span class=\"desc_commands\">" + translationHelper.getTranslation("_hlpSend", languageName) + "</span>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                    htmlToReturn += "                        <img onclick=\"" + ModelHelper.showPopup("popupLogisticsInfo") + "\" src=\"../../../Content/images/logistics.png\" alt=\"Logistics Info\" /><span onclick=\"" + ModelHelper.showPopup("popupLogisticsInfo") + "\" class=\"desc_commands\">Logistics Info</span>";  //bez translacji
                    htmlToReturn += "                        <img onclick=\"" + ModelHelper.showPopup("popupOeNumbers") + "\" src=\"../../../Content/images/oe.png\" alt=\"OE\" /> <span onclick=\"" + ModelHelper.showPopup("popupOeNumbers") + "\" class=\"desc_commands\">OE</span>";
                    htmlToReturn += "                    </div>";
                    htmlToReturn += "                </div>";
                    htmlToReturn += "                <div id=\"searchRightSideTopRightFiltron\">";
                    string filterImg = "                    <img src=\"../../../Content/images/temp/example_filter_english.png\" alt=\"Example\" />";
                    if (languageName == "polish")
                    {
                        filterImg += "                    <img src=\"../../../Content/images/temp/example_filter.png\" alt=\"Example\" />";
                    }   //if            
                    htmlToReturn += filterImg;

                    filterImg = "                    <a href=\"../../../Content/images/temp/example_filter_english.png\" alt=\"Zoom\" />" + translationHelper.getTranslation("_hlpZoom", languageName) + "</a></span>";
                    if (languageName == "polish")
                    {
                        filterImg += "                    <a href=\"../../../Content/images/temp/example_filter.png\" alt=\"Zoom\" />" + translationHelper.getTranslation("_hlpZoom", languageName) + "</a></span>";
                    }   //if            
                    htmlToReturn += filterImg;
                    htmlToReturn += "                </div>";
                    htmlToReturn += "            </div>";
                    htmlToReturn += "</div>";
                }
                else
                {
                    return "<div id=\"ajaxStatementInfo\">" + Translations.translationHelper.getTranslation("_searchNoFilters", languageName) + "</div>";
                }
            } // if wix

            return htmlToReturn;
        }


    }
}
